#!/bin/sh
#
# checkscripts
#
# Build script checker for the Dragora GNU/Linux-Libre website
# (https://www.dragora.org)
#

PROGNAME=checkscripts
COMMANDS='find shellcheck'
BUILD_SCRIPT=build
PAGES_DIR=source/pages
HEADER_SCRIPT=header_params
FOOTER_SCRIPT=footer_params


for cmd in $COMMANDS
do
  command -v shellcheck >/dev/null || \
    { printf '%s\n' "${PROGNAME}: command not found -- $cmd"; exit 1; } 
done

shellcheck -e 2154 -e 1090 "$BUILD_SCRIPT"

for fl in \
  $(find "$PAGES_DIR" -type f -name "$HEADER_SCRIPT" -o -name "$FOOTER_SCRIPT")
do
  shellcheck -s sh -e 2034 "$fl"
done
